<?php

namespace app\api\controller;

use app\api\BaseController;
use app\model\ReportImgModel;
use think\facade\Config;
use think\facade\Filesystem;

class Upload extends BaseController
{
    public function index()
    {
        $file = $this->request->file('image');
        $savename = Filesystem::disk('public')->putFile('img',$file);

        $config = Config::get('filesystem');

        $reportImgModel = ReportImgModel::create([
            'img_url' => $config['disks']['public']['url'].'/'.$savename,
            'host' => $this->request->domain()
        ]);

        return show($reportImgModel);

        
    }

}